package cn.zhl.algorithm._3_并查集;

import cn.zhl.algorithm._3_并查集.impl.*;

/**
 * @program: demos
 * @description:
 * @author: 刘振华
 * @create: 2020-06-12 10:52
 **/
public class TestMain {
	static final int size = 4000000;
	public static void main(String[] args) {
//		test(new QuickFind(size));
//		test(new QuickUnion(size));
		test(new QuickUnionSize(size));
		test(new QuickUnionHeight(size));
		test(new QuickUnionHeightCompress(size));
		test(new QuickUnionHeightPathSplit(size));
	}
	static void test(UnionFind uf){
		for(int i = 0;i<size;i++){
			uf.union((int)(Math.random()*size),(int)(Math.random()*size));
		}
		long start = System.nanoTime();

		for(int i = 0 ;i<size;i++){
			uf.find(i);
		}

		long end = System.nanoTime();
		System.out.println("============时间消耗："+uf.getClass().getSimpleName()+":"+((end-start)/100000));
	}
}
